home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / mig / sprite / mig.sh < prev   
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-07-16  |  4.7 KB  |  165 lines

  1. #!/bin/sh
  2. #
  3. # Mach Operating System
  4. # Copyright (c) 1991,1990 Carnegie Mellon University
  5. # All Rights Reserved.
  6. # Permission to use, copy, modify and distribute this software and its
  7. # documentation is hereby granted, provided that both the copyright
  8. # notice and this permission notice appear in all copies of the
  9. # software, derivative works or modified versions, and any portions
  10. # thereof, and that both notices appear in supporting documentation.
  11. # CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  12. # CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  13. # ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  14. # Carnegie Mellon requests users of this software to return to
  15. #  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  16. #  School of Computer Science
  17. #  Carnegie Mellon University
  18. #  Pittsburgh PA 15213-3890
  19. # any improvements or extensions that they make and grant Carnegie Mellon
  20. # the rights to redistribute these changes.
  21. #
  22. #
  23. # HISTORY
  24. # $Log:    mig.sh,v $
  25. # Revision 1.4  92/04/24  21:52:13  kupfer
  26. # MK73 merge.
  27. # Revision 2.9  92/04/01  19:36:14  rpd
  28. #     Added option -cc arg
  29. #     It informs mig that it should use the C compiler driver to
  30. #     call the preprocessor. The argument gives the name of the 
  31. #     driver and the flags that make it preprocess.
  32. #     [92/03/18            jvh]
  33. # Revision 2.8  92/01/23  15:21:28  rpd
  34. #     Changed to generate a dependency on migcom itself.
  35. #     [92/01/19            rpd]
  36. # Revision 2.7  92/01/14  16:46:20  rpd
  37. #     Removed -theader switched.
  38. #     Fixed dependency file generation to remove /dev/null.
  39. #     [92/01/10            rpd]
  40. # Revision 1.3  91/10/29  22:14:08  kupfer
  41. # MK63 merge.
  42. # Revision 2.6  91/07/31  18:09:45  dbg
  43. #     Allow both -header and -sheader switches.
  44. #     Fix copyright.
  45. #     [91/07/30  17:14:28  dbg]
  46. # Revision 2.5  91/06/25  10:31:42  rpd
  47. #     Added -sheader.
  48. #     [91/05/23            rpd]
  49. # Revision 1.2  91/05/28  16:23:49  kupfer
  50. # Set correct path for cpp & migcom.
  51. # Revision 2.4  91/02/05  17:55:08  mrt
  52. #     Changed to new Mach copyright
  53. #     [91/02/01  17:54:47  mrt]
  54. # Revision 2.3  90/06/19  23:01:10  rpd
  55. #     The -i option takes an argument now.
  56. #     [90/06/03            rpd]
  57. # Revision 2.2  90/06/02  15:05:05  rpd
  58. #     For BobLand: changed /usr/cs/bin/wh to wh.
  59. #     [90/06/02            rpd]
  60. #     Created for new IPC.
  61. #     [90/03/26  21:12:04  rpd]
  62. # 27-May-87  Richard Draves (rpd) at Carnegie-Mellon University
  63. #    Created.
  64. #
  65.  
  66. CPP=/sprite/cmds/cpp
  67. MIGCOM=/sprite/cmds/migcom
  68.  
  69. usecc=false
  70. cppflags=
  71. migflags=
  72. files=
  73.  
  74. # If an argument to this shell script contains whitespace,
  75. # then we will screw up.  migcom will see it as multiple arguments.
  76. #
  77. # As a special hack, if -i is specified first we don't pass -user to migcom.
  78. # We do use the -user argument for the dependencies.
  79. # In this case, the -user argument can have whitespace.
  80.  
  81. until [ $# -eq 0 ]
  82. do
  83.     case "$1" in
  84.     -[qQvVtTrRsS] ) migflags="$migflags $1"; shift;;
  85.     -i    ) sawI=1; migflags="$migflags $1 $2"; shift; shift;;
  86.     -user   ) user="$2"; if [ ! "${sawI-}" ]; then migflags="$migflags $1 $2"; fi; shift; shift;;
  87.     -server ) server="$2"; migflags="$migflags $1 $2"; shift; shift;;
  88.     -header ) header="$2"; migflags="$migflags $1 $2"; shift; shift;;
  89.     -sheader ) sheader="$2"; migflags="$migflags $1 $2"; shift; shift;;
  90.     -iheader ) iheader="$2"; migflags="$migflags $1 $2"; shift; shift;;
  91.  
  92.     -MD ) sawMD=1; cppflags="$cppflags $1"; shift;;
  93.     -cc) usecc=true; CPP="$2"; shift; shift;;
  94.     -* ) cppflags="$cppflags $1"; shift;;
  95.     * ) files="$files $1"; shift;;
  96.     esac
  97. done
  98.  
  99. for file in $files
  100. do
  101.     base="`/usr/bin/basename "$file" .defs`"
  102.     if $usecc; then
  103.         $CPP $cppflags "$file" | $MIGCOM $migflags || exit
  104.     else
  105.             $CPP $cppflags "$file" - ${sawMD+"$base".defs.d~} |
  106.                     $MIGCOM $migflags || exit
  107.     fi
  108.     if [ $sawMD ]
  109.     then
  110.     deps=
  111.     s=
  112.     rheader="${header-${base}.h}"
  113.     if [ "$rheader" != /dev/null ]; then
  114.         deps="${deps}${s}${rheader}"; s=" "
  115.     fi
  116.     ruser="${user-${base}User.c}"
  117.     if [ "$ruser" != /dev/null ]; then
  118.         deps="${deps}${s}${ruser}"; s=" "
  119.     fi
  120.     rserver="${server-${base}Server.c}"
  121.     if [ "$rserver" != /dev/null ]; then
  122.         deps="${deps}${s}${rserver}"; s=" "
  123.     fi
  124.     rsheader="${sheader-/dev/null}"
  125.     if [ "$rsheader" != /dev/null ]; then
  126.         deps="${deps}${s}${rsheader}"; s=" "
  127.     fi
  128.     riheader="${iheader-/dev/null}"
  129.     if [ "$riheader" != /dev/null ]; then
  130.         deps="${deps}${s}${riheader}"; s=" "
  131.     fi
  132. # fixup dependencies, adding a dependency on migcom itself
  133.     if $usecc; then
  134.         { sed 's;^'"$base"'.o;'"$deps"';' < "$base".d; \
  135.         echo "${deps}: ${MIGCOM}"; } > "$base".defs.d
  136.                rm -f "$base".d
  137.  
  138.     else
  139.         { sed 's;^'"$base"'.o;'"$deps"';' < "$base".defs.d~; \
  140.           echo "${deps}: ${MIGCOM}"; } > "$base".defs.d
  141.         rm -f "$base".defs.d~
  142.     fi
  143.  
  144.     fi
  145. done
  146.  
  147. exit 0
  148.